//
//  Account.m
//  NewApp
//
//  Created by  on 12-6-20.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "NAAccount.h"

@implementation NAAccount
@synthesize userID,uid,name,group_id,group_name,nickName,profileImageURL;

- (id)initWithCoder:(NSCoder *)decoder {
	if (self = [super init]) {
        self.userID = (nil == [decoder decodeObjectForKey:kUserID]) ? @"" : [decoder decodeObjectForKey:kUserID];
        self.uid = (nil == [decoder decodeObjectForKey:kUid]) ? @"" : [decoder decodeObjectForKey:kUid];
        self.name = (nil == [decoder decodeObjectForKey:kName]) ? @"" : [decoder decodeObjectForKey:kName];
        self.group_id = (nil == [decoder decodeObjectForKey:kGroupID]) ? @"" : [decoder decodeObjectForKey:kGroupID];
        self.group_name = (nil == [decoder decodeObjectForKey:kGroupName]) ? @"" : [decoder decodeObjectForKey:kGroupName];
        self.nickName = (nil == [decoder decodeObjectForKey:kNickName]) ? @"" : [decoder decodeObjectForKey:kNickName];
        self.profileImageURL = (nil == [decoder decodeObjectForKey:kProfileURL]) ? @"" : [decoder decodeObjectForKey:kProfileURL];
	}
	return self;
}

- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:self.userID forKey:kUserID];
    [encoder encodeObject:self.uid forKey:kUid];
    [encoder encodeObject:self.name forKey:kName];
    [encoder encodeObject:self.group_id forKey:kGroupID];
    [encoder encodeObject:self.group_name forKey:kGroupName];
    [encoder encodeObject:self.nickName forKey:kNickName];
    [encoder encodeObject:self.profileImageURL forKey:kProfileURL];
}


- (id) initWithDictionary:(NSDictionary *) dictionary {
    if (self = [super init]) {
        
        self.userID = (nil == [dictionary objectForKey:@"user_id"]) ? @"" : [dictionary objectForKey:@"user_id"];
        self.uid = (nil == [dictionary objectForKey:@"uid"]) ? @"" : [dictionary objectForKey:@"uid"];
        self.name = (nil == [dictionary objectForKey:@"name"]) ? @"" : [dictionary objectForKey:@"name"];
        self.group_id = (nil == [dictionary objectForKey:@"group_id"]) ? @"" : [dictionary objectForKey:@"group_id"];
        self.group_name = (nil == [dictionary objectForKey:@"group_name"]) ? @"" : [dictionary objectForKey:@"group_name"];
        self.nickName = (nil == [dictionary objectForKey:@"nikename"]) ? @"" : [dictionary objectForKey:@"nikename"];
        self.profileImageURL = (nil == [dictionary objectForKey:@"img"]) ? @"" : [dictionary objectForKey:@"img"];
    }
    
    return self;
}

- (void) dealloc {
    [userID release];
    [uid release];
    [name release];
    [group_id release];
    [group_name release];
    [nickName release];
    [profileImageURL release];
    [super dealloc];
}

@end
